<!DOCTYPE html>
<html lang="zh">
<head>
    <title>王福迎的博客系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <!-- 优先使用 IE 最新版本和 Chrome -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="x5-orientation" content="portrait">
    <!-- UC强制全屏 -->
    <meta name="full-screen" content="yes">
    <!-- QQ强制全屏 -->
    <meta name="x5-fullscreen" content="true">
    <!-- UC应用模式 -->
    <meta name="browsermode" content="application">
    <!-- QQ应用模式 -->
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <!-- 是否启用 WebApp 全屏模式，删除苹果默认的工具栏和菜单栏 -->
    <link rel="stylesheet" href="/static/3part/editor.md-master/css/editormd.preview.css"/>
    <link rel="stylesheet" href="/static/3part/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>
    <link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon"/>
    <script src="/static/3part/editor.md-master/examples/js/jquery.min.js" type="text/javascript"></script>
    <script src="/static/3part/bootstrap-3.3.7-dist/js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/static/3part/editor.md-master/editormd.min.js" type="text/javascript"></script>
    <script src="/static/3part/editor.md-master/lib/marked.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/prettify.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/raphael.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/underscore.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/sequence-diagram.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/flowchart.min.js"></script>
    <script src="/static/3part/editor.md-master/lib/jquery.flowchart.min.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse nav-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <a href="#" id="title" class="navbar-brand">我的博客</a>
        </div>
        <div class="pull-right">
				<span class="navbar-brand">
					欢迎您！
				</span>
        </div>
    </div>
</nav>
<div class="container">
    <div class="container">
        <a href="/edit" target="_blank" class="pull-right btn btn-primary">写新文章</a>
        <a href="/edit?id=index" class="pull-right" style="margin-right: 20px; margin-top: 10px" target="_blank">修改</a>
        <div class="dropdown pull-right" style="margin-right: 20px; margin-top: 10px">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                导出
                <b class="caret"></b>
            </a>
            <ul class="dropdown-menu">
                <li><a href="/static/article/index.md">*.md</a></li>
                <li><a onclick="_exportHtml()">*.html</a></li>
                <li><a onclick="window.print()">*.pdf</a></li>
            </ul>
        </div>
    </div>

    <div id="test-editormd-view">
        <textarea style="display:none;" name="test-editormd-markdown-doc">###Hello world!</textarea>
    </div>
</div>

<footer>
    <nav class="navbar navbar-inverse nav-fixed-bottom" role="navigation" style="margin: 0px">
        <div class="container">
            <div class="navbar-header">
                <span class="navbar-brand">博客系统作者：王福迎</span>
            </div>
        </div>
    </nav>
</footer>

<!-- bShare -->
<a class="bshareDiv" href="http://www.bshare.cn/share">分享按钮</a>
<script type="text/javascript" charset="utf-8" src="http://static.bshare.cn/b/buttonLite.js#uuid=&amp;style=5&amp;fs=4&amp;bgcolor=LightBlue"></script>
</body>
<script>
    var testEditormdView;
    $(function () {
        // alert('{{.ID}}')
        $.get("/static/article/index.md", function (markdown) {
            testEditormdView = editormd.markdownToHTML("test-editormd-view", {
                markdown: markdown,//+ "\r\n" + $("#append-test").text(),
                //htmlDecode      : true,       // 开启 HTML 标签解析，为了安全性，默认不开启
                htmlDecode: "style,script,iframe",  // you can filter tags decode
                //toc             : false,
                tocm: true,    // Using [TOCM]
                //tocContainer    : "#custom-toc-container", // 自定义 ToC 容器层
                //gfm             : false,
                //tocDropdown     : true,
                // markdownSourceCode : true, // 是否保留 Markdown 源码，即是否删除保存源码的 Textarea 标签
                emoji: true,
                taskList: true,
                tex: true,  // 默认不解析
                flowChart: true,  // 默认不解析
                sequenceDiagram: true  // 默认不解析
            });

            //console.log("返回一个 jQuery 实例 =>", testEditormdView);

            // 获取Markdown源码
            //console.log(testEditormdView.getMarkdown());

            //alert(testEditormdView.getMarkdown());
        });
    });

    function _exportHtml() {
        var htmlContent = $('#test-editormd-view').html()
        // console.log(htmlContent)
        save_file("export.html", htmlContent)
    }

    //保存到本地
    function save_file(filename, content) {
        var win = window.open('', '', 'top=0,left=0');
        win.document.write(content);
        win.document.execCommand('SaveAs', '', filename)
        // win.close();
    }

    function _exportMd() {
        window.location.href = "/static/article/index.md";
    }

</script>
</html>